/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.worlds;

import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.worlds.ui.edge.EMain;
import net.worlds.ui.edge.MenuMain;

/**
 *
 * @author Jacob
 */
public class MenuView extends MainView{
    private MenuMain ui;
    private long changeTime;
    private BufferedImage image;
    public MenuView()
    {
        ui = new MenuMain(this, width, height);
        overlayUI = ui;
        Main.loading = false;
    }
    @Override
    protected void drawGameUI(Graphics2D g, World world, int viewWidth, int viewHeight, float worldWidth, float worldHeight) {

    }
    
    public void draw(Graphics2D g, int viewWidth, int viewHeight, Rectangle clip)
    {
        if(System.currentTimeMillis() - changeTime > 7 * 1000)
        {
            int r = (int) (Math.random() * 7)+1;
            try {
                image = AssetManager.loadImage("loading_"+r, "resource://title/"+r+".jpg");
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            changeTime = System.currentTimeMillis();
        }
        g.drawImage(image, 0, 0, viewWidth, viewHeight, null);
        overlayUI.render(g);
    }

    @Override
    public EMain getOverlay() {
        return ui;
    }

    @Override
    public EMain getTop() {
        return null;
    }

    @Override
    public boolean eMouseDrag(int b, int x, int y) {
        return ui.eMouseDrag(b, x, y);
    }

    @Override
    public boolean eMouseDown(int b, int x, int y) {
        return ui.eMouseDown(b, x, y);
    }

    @Override
    public boolean eMouseUp(int b, int x, int y) {
        return ui.eMouseUp(b, x, y);
    }

    @Override
    public boolean eMouseMove(int x, int y) {
        return ui.eMouseMove(x, y);
    }
    @Override
    public void setSize(int x, int y)
    {
        super.setSize(x, y);
        ui.setSize(x, y);
    }
    
}
